package com.youxue.teachin.set.main.binder;

import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.Navigator;
import com.library.uiframework.widget.imageview.NetworkImageView;
import com.library.xtype.DefaultNuwaItemBinder;
import com.youxue.teachin.R;
import com.youxue.teachin.set.main.vo.UserHeadVO;

/**
 * 在此写用途
 *
 * @author: zhiwei
 * @date: 2017-10-05 21:51
 * @version: 9.1.0
 */
public class UserHeadBinder extends DefaultNuwaItemBinder<UserHeadVO> implements OnClickListener{
    private View mRootView;
    private NetworkImageView mUserIcon;
    private ImageView mRightArrows;
    private TextView mUserName;
    private TextView mUserDes;

    UserHeadVO mUserHeadVO;

    @Override
    public View onCreateView(View convertView, ViewGroup parent, LayoutInflater inflater) {
        View view = inflater.inflate(R.layout.set_main_user_head_binder, parent, false);
        initView(view);
        return view;
    }

    @Override
    public void onBindView(int positionOfFeeds, View convertView, ViewGroup parent, UserHeadVO vo) {
        mUserHeadVO = vo;
        mUserIcon.setPlaceholderImage(R.drawable.default_avatar)
            .setUrl(vo.mIcon);
        mUserName.setText(vo.mName);
        mUserDes.setText(vo.mDestory);
    }

    private void initView(View rootView) {
        mRootView = rootView;
        mUserIcon = (NetworkImageView)rootView.findViewById(R.id.user_icon);
        mRightArrows = (ImageView)rootView.findViewById(R.id.right_arrows);
        mUserName = (TextView)rootView.findViewById(R.id.user_name);
        mUserDes = (TextView)rootView.findViewById(R.id.user_des);

        mRootView.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        new Navigator.Builder()
            .setPageName("set_my_detail").build().open();
    }
}
